// 源插件
import React, { Fragment, PureComponent } from 'react';
import { DateDiff, DateStamp, FormatnumberZero, Mover, NumberDivide } from '@/function.js';
// 视图插件
import { Button, Card, Divider, Form, message, notification } from 'antd';
// 外部组件
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import StandardTablePro from '@/components/UpgradeStandardTable/StandardTablePro';
import { connect } from 'dva';
import ExportJsonExcel from '@/components/XLSXOUT/js-export-excel-custom';
// css OR less预编译器

// 图片

/**
 *  Describe:数据连接
 */

@connect(({ aqdq, loading }) => ({
  aqdq,
  loading: loading.models.aqdqRule,
}))
@Form.create()
class BillExport extends PureComponent {
  componentWillMount() {}

  /**
   *  Describe:当前状态
   */

  state = {
    listLoading: false, // 加载状态
    dataSource: {
      data: [],
      total: [],
      code: 0,
    },
    addVisible: false,
    updateVisible: false,
    row: {},
  };

  outXlsx() {
    const { dispatch } = this.props;
    dispatch({
      type: 'bill/BillDataExport',
      callback: res => {
        const option = {};
        option.fileName = 'ProductData';
        option.datas = [
          {
            sheetData: res.ProductDataDetail,
            sheetName: 'ProductDataDetail',
            sheetFilter: [
              'id',
              'bill',
              'stockName',
              'payPrice',
              'closePrice',
              'exercisePriceThan',
              'exercisePrice',
              'appearPriceThan',
              'appearPrice',
              'date',
              'redeemPeriod',
              'investmentMoney',
              'atMaturity',
              'nowPrice',
              'nowPriceGetTime',
              'earnDate',
              'earnDateGetDate',
              'eventRemark',
              'riskLevelRemark',
              'industry',
              'status',
              'gmtModified',
              'ki',
              'pid',
              'udvsPPrice',
              'udvsEPrice',
            ],
            sheetHeader: [
              'id',
              'bill',
              'stockName',
              'payPrice',
              'closePrice',
              'exercisePriceThan',
              'exercisePrice',
              'appearPriceThan',
              'appearPrice',
              'date',
              'redeemPeriod',
              'investmentMoney',
              'atMaturity',
              'nowPrice',
              'nowPriceGetTime',
              'earnDate',
              'earnDateGetDate',
              'eventRemark',
              'riskLevelRemark',
              'industry',
              'status',
              'gmtModified',
              'ki',
              'pid',
              'udvsPPrice',
              'udvsEPrice',
            ],
            columnWidths: [
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 130 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 130 },
              { wpx: 130 },
              { wpx: 130 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 130 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
            ],
          },
          {
            sheetData: res.productData,
            sheetName: 'productData',
            sheetFilter: [
              'id',
              'productID',
              'transactionDate',
              'marketPrice',
              'executivePrice',
              'redeemPrice',
              'price',
              'releaseDate',
              'redeemPriceDate',
              'finalDate',
              'date',
              'x',
              's',
              'p',
              'd',
              'billType',
              'interest',
              'floatProfit',
              'currency',
              'investmentMoney',
              'maxInvestmentDate',
              'redeemPeriod',
              'publisher',
              'isRelease',
              'level',
              'levelRemark',

              'levelTime',
              'px',
              'gmtModified',
              'status',
              'worstStock',
              'worstPrice',
              'liquidationRate',
              'iscnumber',
              'frncoupon',
            ],
            sheetHeader: [
              'id',
              'productID',
              'transactionDate',
              'marketPrice',
              'executivePrice',
              'redeemPrice',
              'price',
              'releaseDate',
              'redeemPriceDate',
              'finalDate',
              'date',
              'x',
              's',
              'p',
              'd',
              'billType',
              'interest',
              'floatProfit',
              'currency',
              'investmentMoney',
              'maxInvestmentDate',
              'redeemPeriod',
              'publisher',
              'isRelease',
              'level',
              'levelRemark',

              'levelTime',
              'px',
              'gmtModified',
              'status',
              'worstStock',
              'worstPrice',
              'liquidationRate',
              'iscnumber',
              'frncoupon',
            ],
            columnWidths: [
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 130 },
              { wpx: 100 },
              { wpx: 180 },
              { wpx: 180 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 160 },
              { wpx: 130 },
              { wpx: 130 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 130 },
              { wpx: 100 },
              { wpx: 130 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 100 },
              { wpx: 200 },
            ],
          },
        ];
        const toExcel = new ExportJsonExcel(option);
        toExcel.saveExcel();
      },
    });
  }

  render() {
    const { addVisible, updateVisible, row, dataSource } = this.state;
    return (
      <PageHeaderWrapper>
        <Card>
          <Button type="primary" onClick={this.outXlsx.bind(this)}>
            导出票据
          </Button>
        </Card>
      </PageHeaderWrapper>
    );
  }

  componentDidMount() {}

  componentWillUnmount() {}
}

export default BillExport;
